# Path to your oh-my-zsh configuration.
ZSH=$HOME/gits/oh-my-zsh

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="random"
#ZSH_CUSTOM="/home/eddie/.oh-my-zsh/custom/"
# Example aliases
# alias zshconfig="mate ~/.zshrc"ZZ
# alias ohmyzsh="mate ~/.oh-my-zsh"

# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"

# Comment this out to disable bi-weekly auto-update checks
#DISABLE_AUTO_UPDATE="true"
DISABLE_UPDATE_PROMPT=true


# Uncomment to change how often before auto-updates occur? (in days)
# export UPDATE_ZSH_DAYS=13

# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"

# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment following line if you want to disable command autocorrection
# DISABLE_CORRECTION="true"

# Uncomment following line if you want red dots to be displayed while waiting for completion
COMPLETION_WAITING_DOTS="true"

# Uncomment following line if you want to disable marking untracked files under
# VCS as dirty. This makes repository status check for large repositories much,
# much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(archlinux cp copydir copyfile extract sudo command-not-found git git-extras python pyenv grunt tmux colored-man gpg-agent nyan rsync git-prompt kate npm pass suse emacs colorize history systemd git-extras screen zsh-syntax-highlighting history-substring-search emoji-clock zsh-dircolors-solarized)

source $ZSH/oh-my-zsh.sh

# Customize to your needs...
export EDITOR="emacsclient -a \"\" -t"
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
#export DE="gnome"
export LANG=en_GB.UTF-8
export PATH="/usr/lib/ccache/bin/:/home/eddie/.gem/ruby/2.1.0/bin:$PATH"
LIBVA_DRIVER_NAME=vdpau
VDPAU_DRIVER=nvidia
export SHOWTERM_SERVER=http://linuxdistrocommunity.com:3000
feed() {
	if [ ! -d $FEED_BOOKMARKS ]; then mkdir $FEED_BOOKMARKS; fi

	if [ ! -n "$1" ]; then
		echo -e "\\n \\e[04mUsage\\e[00m\\n\\n   \\e[01;37m\$ feed \\e[01;31m<url>\\e[00m \\e[01;31m<new bookmark?>\\e[00m\\n\\n \\e[04mSee also\\e[00m\\n\\n   \\e[01;37m\$ deef\\e[00m\\n"
		return 1;
	fi

	local rss_source="$(curl --silent $1 | sed -e ':a;N;$!ba;s/\n/ /g')";

	if [ ! -n "$rss_source" ]; then
		echo "The feed is empty";
		return 1;
	fi

	# THE RSS PARSER
	# The characters "£, §" are used as metacharacters. They should not be encountered in a feed...
	echo -e "$(echo $rss_source | \
		sed -e 's/&gt;/>/g' \
		-e 's/&lt;/</g' \
		-e 's/<\/a>/£/g' \
		-e 's/href\=\"/§/g' \
		-e 's/<title>/\\n\\n\\n   :: \\e[01;31m/g' -e 's/<\/title>/\\e[00m ::\\n/g' \
		-e 's/<link>/ [ \\e[01;36m/g' -e 's/<\/link>/\\e[00m ]/g' \
		-e 's/<description>/\\n\\n\\e[00;37m/g' -e 's/<\/description>/\\e[00m\\n\\n/g' \
		-e 's/<p>\|<br\s*\/\?>/\n/g' \
		-e 's/<b>\|<strong>/\\e[01;30m/g' -e 's/<\/b>\|<\/strong>/\\e[00;37m/g' \
		-e 's/<u>/\\e[4;37m/g' -e 's/<\/u>/\\e[00;37m/g' \
		-e 's/<b>\|<code>/\\e[00m/g' -e 's/<\/b>\|<\/code>/\\e[00;37m/g' \
		-e 's/<a[^§]*§\([^\"]*\)\"[^>]*>\([^£]*\)[^£]*£/\\e[01;31m\2\\e[00;37m \\e[01;34m[\\e[00;37m \\e[04m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g' \
		-e 's/<li>/\n \\e[01;34m*\\e[00;37m /g' \
		-e 's/<!\[CDATA\[\|\]\]>\|>\s*<//g' \
		-e 's/<[^>]*>/ /g' \
		-e 's/[<>£§]//g')\n\n";
	# END OF THE RSS PARSER

	if [ -n "$2" ]; then
		echo "$1" > $FEED_BOOKMARKS/$2
		echo -e "\\n\\t\\e[01;37m==> \\e[01;31mBookmark saved as \\e[01;36m\\e[04m$2\\e[00m\\e[01;37m <==\\e[00m\\n"
	fi
}

deef() {
	if test -n "$1"; then
		if [ ! -r "$FEED_BOOKMARKS/$1" ]; then
			echo -e "\\n \\e[01;31mBookmark \\e[01;36m\\e[04m$1\\e[00m\\e[01;31m not found.\\e[00m\\n\\n \\e[04mType:\\e[00m\\n\\n   \\e[01;37m\$ deef\\e[00m (without arguments)\\n\\n to get the complete list of all currently saved bookmarks.\\n";
			return 1;
		fi
		local url="$(cat $FEED_BOOKMARKS/$1)";
		if [ ! -n "$url" ]; then
			echo "The bookmark is empty";
			return 1;
		fi
		echo -e "\\n\\t\\e[01;37m==> \\e[01;31m$url\\e[01;37m <==\\e[00m"
		feed "$url";
	else
		echo -e "\\n \\e[04mUsage\\e[00m\\n\\n   \\e[01;37m\$ deef \\e[01;31m<bookmark>\\e[00m\\n\\n \\e[04mCurrently saved bookmarks\\e[00m\\n";
		for i in $(find $FEED_BOOKMARKS -maxdepth 1 -type f);
			do echo -e "   \\e[01;36m\\e[04m$(basename $i)\\e[00m";
		done;
		echo -e "\\n \\e[04mSee also\\e[00m\\n\\n   \\e[01;37m\$ feed\\e[00m\\n";
	fi;
}

da(){
watch -ctn 1 "(echo -e '\033[32mGID\t\t Name\t\t\t\t\t\t\t%\tDown\tSize\tSpeed\tUp\tS/L\tTime\033[36m'; \
diana list| cut -c -112; echo -e '\033[37m'; diana stats)"
}

for sd_cmd in systemctl systemd-analyze systemd-run; do
    alias $sd_cmd='DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/dbus/user_bus_socket" '$sd_cmd
done

source /etc/profile.d/vte.sh
source /usr/share/doc/pkgfile/command-not-found.zsh



## workaround for handling TERM variable in multiple tmux sessions properly from http://sourceforge.net/p/tmux/mailman/message/32751663/ by Nicholas Marriott
#if [[ -n ${TMUX} && -n ${commands[tmux]} ]];then
#        case $(tmux showenv TERM 2>/dev/null) in
#                *256color) ;&
#                TERM=fbterm)
#                        TERM=screen-256color ;;
#                *)
#                        TERM=screen
# #       esac
#fi

reminder() {                                                                
  echo notify-send "$2" | at now + $1 min &>/dev/null
  echo "Reminder: $2 set for $1 minutes from now"
}

PATH="/home/eddie/perl5/bin${PATH+:}${PATH}"; export PATH;
PERL5LIB="/home/eddie/perl5/lib/perl5${PERL5LIB+:}${PERL5LIB}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/eddie/perl5${PERL_LOCAL_LIB_ROOT+:}${PERL_LOCAL_LIB_ROOT}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/eddie/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/eddie/perl5"; export PERL_MM_OPT;

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
